home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18470 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  67 lines

  1. Path: saluki-news.wham.siu.edu!usenet
  2. From: Samer Kanjo <scamer@siu.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Class libraries
  5. Date: Sat, 20 Apr 1996 18:00:27 -0500
  6. Organization: Southern Illinois University - Carbondale
  7. Message-ID: <31796C8B.583A@siu.edu>
  8. NNTP-Posting-Host: rm320217.cag.siu.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.01 (Win95; I)
  13.  
  14. I was having trouble with the array class iterator. Here is the code:
  15.  
  16. typedef TDArrayAsVector<TInt> arrayType;
  17. typedef TDArrayAsVectorIterator<TInt> iteratorType;
  18.  
  19. const int cSize = 100;
  20.  
  21. struct COLORDER
  22. {
  23.    arrayType *ident;
  24.    arrayType *compl;
  25. };
  26.  
  27. struct COLORDER colOrder[cSize];
  28. for(int col = 0; col < cSize; col++)
  29. {
  30.    colOrder[col].ident = new arrayType(0,0,1);
  31.    colOrder[col].compl = new arrayType(0,0,1);
  32. }
  33.     .
  34.     .
  35.     .
  36. Some items are added to some of the arrays ident and compl.
  37.     .
  38.     .
  39.     .
  40. for(int col = 0; col < cSize; col++)
  41. {
  42.    for(iteratorType identIter(*(colOrder[col].ident)); identIter; identIter++)
  43.     cout << identIter.Current() << endl;
  44.    for(iteratorType complIter(*(colOrder[col].compl)); complIter; complIter++)
  45.     cout << complIter.Current() << endl;
  46. }
  47.  
  48. The last for loop was executed by a function call made from a window's Paint
  49. member function. Basically I need to display the contents of the two arrays
  50. on the screen in a window with scrollbars. The above code is not the exact
  51. way I display the data--the for loops are the same but the couts are not. 
  52. Whenever the screen is resized or the scrollbars are moved the window is 
  53. invalidated.
  54.  
  55. Sometimes it displays fine and I am able to use the scrollbars to look at 
  56. all of the data. The problem is an error in the vectimp.h file. It is always
  57. the same line in the file that causes the error. I unfortunately don't have
  58. the line number with me now but I can provide it if can help.
  59.  
  60. Is the cause of this error the result of the code in my last for loop or
  61. is it a bug in the array template class?
  62.  
  63. I would appreciate any help.
  64.  
  65. Samer Kanjo
  66. scamer@siu.edu
  67.